<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h3>标题一</h3>
    <h3>标题二</h3>
    <h3>标题三</h3>


    <script>
        //Array.from()方法将类数组转化为真正的数组
        //类数组有三类：1. arguments 2.元素集合 3. 类似数组的对象
        //类数组只能使用数组的读取方式和length属性，不能使用数组方法

        //arguments
        function add(){
            //arguments可用于读取传进来的参数
            console.log(arguments);
            console.log(arguments[0]);

            var result = Array.from(arguments);
            result.push(40);
            console.log(result);

        }
        
        add(10, 20, 30);

        //元素集合
        let titles = document.querySelectorAll("h3");
        console.log(titles);
        console.log(Array.from(titles));


        //类似数组的对象
        var user = {
            "0":"iwen",
            "1":20,
            "2":"男",
            length:3
        }
        console.log(user[2]);
        console.log(user.length);
        console.log(Array.from(user));

        //Array.of, 用于将一组值转化为数组
        console.log(Array.of(10, 20, 30));
        //创建一个空间为3的空数组
        console.log(Array(3));



    </script>
</body>
</html>